package com.example.demo.request;


import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

//@Schema(description = "使用参数执行查询请求")
public class ExecuteQueryWithParamsRequest {

    //@Schema(description = "数据库类型", example = "mysql", allowableValues = {"mysql", "postgresql", "oracle", "sqlserver"})
    @NotBlank(message = "数据库类型不能为空")
    private String dbType;

    //@Schema(description = "主机地址", example = "localhost")
    @NotBlank(message = "主机地址不能为空")
    private String host;

    //@Schema(description = "端口号", example = "3306")
    @NotNull(message = "端口号不能为空")
    @Min(value = 1, message = "端口号必须大于0")
    @Max(value = 65535, message = "端口号不能超过65535")
    private Integer port;

    //@Schema(description = "数据库名称", example = "test_db")
    @NotBlank(message = "数据库名称不能为空")
    private String databaseName;

    //@Schema(description = "用户名", example = "root")
    @NotBlank(message = "用户名不能为空")
    private String username;

    //@Schema(description = "密码", example = "password")
    @NotBlank(message = "密码不能为空")
    private String password;

    //@Schema(description = "要执行的SQL查询语句", example = "SELECT * FROM users LIMIT 10")
    @NotBlank(message = "SQL语句不能为空")
    private String sql;

    //@Schema(description = "返回结果的最大行数", example = "5", defaultValue = "5")
    @Min(value = 1, message = "限制行数必须大于0")
    @Max(value = 1000, message = "限制行数不能超过1000")
    private Integer limit = 5;

    //@Schema(description = "查询超时时间（秒）", example = "30", defaultValue = "30")
    @Min(value = 1, message = "超时时间必须大于0秒")
    @Max(value = 300, message = "超时时间不能超过300秒")
    private Integer timeoutSeconds = 30;

    // 构造函数
    public ExecuteQueryWithParamsRequest() {}

    // Getter和Setter方法
    public String getDbType() {
        return dbType;
    }

    public void setDbType(String dbType) {
        this.dbType = dbType;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public String getDatabaseName() {
        return databaseName;
    }

    public void setDatabaseName(String databaseName) {
        this.databaseName = databaseName;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    public Integer getTimeoutSeconds() {
        return timeoutSeconds;
    }

    public void setTimeoutSeconds(Integer timeoutSeconds) {
        this.timeoutSeconds = timeoutSeconds;
    }

    @Override
    public String toString() {
        return "ExecuteQueryWithParamsRequest{" +
                "dbType='" + dbType + '\'' +
                ", host='" + host + '\'' +
                ", port=" + port +
                ", databaseName='" + databaseName + '\'' +
                ", username='" + username + '\'' +
                ", password='[PROTECTED]'" +
                ", sql='" + sql + '\'' +
                ", limit=" + limit +
                ", timeoutSeconds=" + timeoutSeconds +
                '}';
    }
}